<style>
    * {
      padding: 0px;
      margin: 0px;
    }
    html,
    body,
    #root {
      width: 100%;
      height: 100%;
      overflow: hidden;  
    }
    #root {
      display: flex;
    }
  
    .menu {
      width: 200px;
      height: 100%;
      background: #263445;
      transition: all 0.3s;
    }
    .menu li {
      width: 100%;
      height: 50px;
      line-height: 50px;
      text-align: center;
      color: #fff;
    }
    .menu li:hover {
      background: yellow;
      color: black;
      cursor: pointer;
    }
  
    .main {
      flex: 1;
      background: #fff;
      height: 50px;
      /* border-bottom: solid 5px black; */
      box-shadow: 0 1px 4px rgb(0 21 41 / 8%);
    }

    


    
    .main .top {
      display: flex;
      padding: 0px 10px;
      height: 100%;
      align-items: center;
      justify-content: space-between;
    }
    .main .content {
      width: 90%;
      margin: auto;
      margin-top: 50px;
    }
    .icon {
    width: 1em;
    height: 1em;
    vertical-align: -0.15em;
    fill: currentColor;
    overflow: hidden;
    }
  </style>

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/animate.css@3.5.1" />
<link rel="stylesheet" href="//at.alicdn.com/t/font_3232548_py4ff35237s.css"></link>
<link rel="stylesheet" href="//at.alicdn.com/t/font_3232589_r1osm9qb00d.css"></link>


<div id="root">
    <div class="menu" ref='menu'>
        <ul>
            <li @click="who='index'">
                <i class='iconfont icon-shuanglieliebiao'></i>
                {{menuWidth=='200px'?'后台首页':''}}
            </li>
            <li @click="who='goods'">
                <i class='iconfont icon-shuanglieliebiao'></i>
                {{menuWidth=='200px'?'商品管理':''}}
            </li>
            <li @click="who='orders'">
                <i class='iconfont icon-shuanglieliebiao'></i>
                {{menuWidth=='200px'?'订单管理':''}}
            </li>
            <li @click="who='users'">
                <i class='iconfont icon-shuanglieliebiao'></i>
                {{menuWidth=='200px'?'用户管理':''}}
            </li>
        </ul>
    </div>
    <div class="main">
      <div class="top">
          <div>
            <i :class='classArr' @click='changeMenuWidthFn'></i>
            <span style="display:inline-block">首页 &gt;</span>
            <span 
              v-for='item in [
                {url:"index",title:"后台首页"},
                {url:"goods",title:"商品分类"},
                {url:"orders",title:"商品规格"},
                {url:"users",title:"商品管理"},
              ]'
              v-if="who==item.url"
              class="animated fadeInRight"
              style="display:inline-block"
            
            >{{item.title}}</span>
          </div>
      </div>
      <div class="content"></div>
      <transition enter-active-class="animated fadeInRight">
          <component :is='who'></component>
      </transition>
    </div>
  </div>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script>
    // 1 盒模型menu、盒模型main两栏布局 > top头部、content内容
    // 2 动态组件（menu菜单点击变化、content显示对应内容）
    // 3 加特效  先写transition   然后引入库 调试即可
    Vue.component('index',{
        template:`<fieldset>
      <legend>后台首页</legend>
      <h1>后台首页</h1>
    </fieldset>`,
    })
    Vue.component('goods',{
        template:`<fieldset>
      <legend>商品分类</legend>
      <h1>商品分类</h1>
    </fieldset>`,
    })
    Vue.component('orders',{
        template:`<fieldset>
      <legend>商品规格</legend>
      <h1>商品规格</h1>
    </fieldset>`,
    })
    Vue.component('users',{
        template:`<fieldset>
      <legend>商品管理</legend>
      <h1>商品管理</h1>
    </fieldset>`,
    })
    const vm = new Vue({
      el: "#root",
      data: {
          who:"index",
          menuWidth:"200px",
          classArr:['iconfont','icon-shouqicaidan'],
      },
      methods:{
        changeMenuWidthFn(){
            if(this.classArr.indexOf('icon-shouqicaidan')!=-1){
                this.classArr.pop()
                this.classArr.push('icon-zhankaicaidan')
                this.$refs.menu.style.width='64px'
                this.menuWidth='64px'
            }else{
                this.classArr.pop()
                this.classArr.push('icon-shouqicaidan')
                this.$refs.menu.style.width='200px'
                this.menuWidth='200px'
            }
            }
        },
        computed:{
        menuShouCp(){
            return this.menuWidth=='200px'?'首页':''
        }
    }
    });
</script>
  